package com.gxuwz.medical.web.servlet;

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Method;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 抽象基类
 * 
 * @author 演示
 * 
 */
public abstract class BaseServlet extends HttpServlet {

	@Override
	protected void service(HttpServletRequest req, HttpServletResponse resp) throws UnsupportedEncodingException{
	
	        
			req.setCharacterEncoding("utf-8");
		
			resp.setContentType("text/html;charset=utf-8");
			
			String methodName = req.getParameter("method");
			
			
			try {
				
				Class cla = this.getClass();
				
				Method m = cla.getMethod(methodName, HttpServletRequest.class,
						HttpServletResponse.class);
				
				m.invoke(this, req, resp);
			} catch (Exception e) {
				e.printStackTrace();
			}
	}
}
